﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    public class SomeService
    {
        private readonly IEventBus _eventBus;
        public SomeService(IEventBus eventBus)
        {
            _eventBus = eventBus;
            _eventBus.Subscribe<DoSomethingEvent>(DoSomethingEventHandle);
        }

        private void DoSomethingEventHandle(DoSomethingEvent eventData)
        {
            Console.WriteLine($"Received event with message: {eventData.Message}");
        }

        public void DoSomething()
        {
            // 触发事件
            _eventBus.Publish(new DoSomethingEvent { Message = "Hello, Event Bus!" });
        }
    }
}
